<?php
require 'include/global.php';
require_once 'include/train_db.php';
$smarty->compile_check = true;
accessblock(array("Trial"));

$id = $_GET[id]+0;

$sql    = "  SELECT * FROM `pa_recuiter` WHERE `rc_id`= '".$id."' AND `rc_pristatus` = 0 ";
$list = $DB->fetch_one_array($sql);
if( $id<1 ||empty($list)){
   echo "<meta http-equiv=\"refresh\" content=\"0;URL=errorall.php?errid=rc_1004\">";
   exit;
}

//all my jobs
$sql = "SELECT jo_id,jo_title FROM pa_job WHERE jo_uid = '".$id."' AND jo_utype='recruiter' AND jo_status <> '3' ORDER BY jo_id DESC";
$tp_jobs = $DB->fetch_all($sql);
if(!empty($tp_jobs)){
	foreach($tp_jobs as $job){
		$jobArr[$job['jo_id']] = $job['jo_title'];
	}
}
//all selected jobs
if(trim($list[rc_top3_1]) != ''){
	$jobIds = explode(",",$list[rc_top3_1]);
	foreach($jobIds as $id){
		$jobsSelected[] = '<p><a href="jobaction.php?action=view&id='.$id.'">'.substr($jobArr[$id],0,32).'</a></p>';
	}
}
$jobs = @implode("",array_slice($jobsSelected,0,11));
$smarty->assign('jobs',$jobs);

$list[rc_uploadfile]  = (file_exists("./uploadfiles/recruiter/".$list[rc_uploadfile])&&$list[rc_uploadfile]!='')?$list[rc_uploadfile]:"noimages.jpg";
$list[rc_state]       = $state[$list[rc_state]];
$list[rc_country]     = $country[$list[rc_country]];
$list[rc_industry]    = ($list[rc_industry] > 0 )?$jobcategory[$list[rc_industry]]:"0";
$list[rc_generalarea] = ($list[rc_generalarea]>0)?$service[$list[rc_generalarea]]:"0";
$list[rc_primaryarea] = (($list[rc_pristate]>0)?$state[$list[rc_pristate]]:"Not Available").",".(($list[rc_pricountry]>0)?$country[$list[rc_pricountry]]:"Not Available");
$list[rc_recruit]     = ($list[rc_topspecialty]!=0)?$jobfunction[$list[rc_topspecialty]]:"N/A";
$list[rc_website]     = changeURL($list[rc_website]);

$tmp1 = $tmp2 = array();
if($list[rc_topspecialty] != ''){
	$_tmp1 = @explode(",",$list[rc_topspecialty]);
	if($list[rc_morespecialty] != ''){
	$_tmp2 = @explode(",",$list[rc_morespecialty]);
	$_tmp1 = array_unique(array_merge($_tmp1,$_tmp2));
	}
	if(!empty($_tmp1)){
		foreach($_tmp1 as $v){
			$myspecialty .= "<li>".$jobfunction[$v]."</li>\n";
		}
	}
	$smarty->assign("myspecialty",$myspecialty);
}

if(!empty($list[rc_hrexperience])){
	$_tmp = @explode(",",$list[rc_hrexperience]);
	foreach($_tmp as $v){
		$hr .= "<li>".$hrExperience[$v]."</li>\n";
	}
	$smarty->assign("hr",$hr);
}
if(!empty($list[rc_moreindustry])){
	$_tmp = @explode(",",$list[rc_moreindustry]);
	foreach($_tmp as $v){
		$industry .= "<li>".$jobcategory[$v]."</li>\n";
	}
	$smarty->assign("industry",$industry);
}

//show the invite button
//arefriends
if( $_SESSION['uid'] <> $list['rc_id'] && $list['rc_share'] == 1){
	$arefriends = (areFriends($list['rc_id'],$_SESSION['uid']))?1:0;
	if( $arefriends == 0){
		if(isSentRequest($_SESSION['uid'],$list['rc_id'])){
			$smarty->assign("isSentRequest",1);
		}else{
			$smarty->assign("showconnect",1);
		}
	}
	if( $arefriends == 1 ){
		$smarty->assign("connected",1);
	}
}
if($_SESSION['uid'] == $list['rc_id']){
	$smarty->assign("myprofile",1);
}

$smarty->assign('list',$list);
$smarty->assign('jquery',1);
$smarty->assign('fancybox',1);

$smarty->display('header.tpl');
$smarty->display('recruiterdetail.tpl');
$smarty->display('recruiterright.tpl');
$smarty->display('footer.tpl');


?>
